﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using BeanboxSoftware.BeanProxy;
using Microsoft.CSharp;
using System.CodeDom.Compiler;

namespace BeanProxyTest
{
  [TestClass]
  public class InterfaceTest
  {
    public interface Interface<T>
    {
      int Simple { get; }

      T Create { get; }
      void Destroy();
    }

    [TestMethod]
    public void SimpleInterfaceTest()
    {
      var proxy = ProxyManager.CreateProxy<Interface<Action>>();
      var config = ProxyManager.GetProp<int>(proxy, () => proxy.Simple);
      config.Return = 4;

      Assert.AreEqual(4, proxy.Simple);

      bool called = false;
      var create = ProxyManager.GetProp<Action>(proxy, () => proxy.Create);
      create.Return = () => { called = true; };

      Action fp = proxy.Create;
      Assert.IsFalse(called);
      fp();
      Assert.IsTrue(called);
    }
  }
}


////
